#ifndef UTIL_H
#define UTIL_H
#include <QJsonObject>
#include <QNetworkReply>

#include <functional>

#include <QWebSocket>
#include <QJsonDocument>
extern void handler_response(QWidget *parent, QNetworkReply *reply ,std::function<void(const QJsonObject &)> success_callback);
extern void request_server(QWidget *parent,QNetworkAccessManager *network,const QString &url,const QString &params,std::function<void(const QJsonObject &)> success_back);
extern void handle_server_result(const QByteArray &message,std::function<void(const int &code,const QJsonDocument &rep_data,const QString &tag)> success_callback,std::function<void (const int &code,const int &rep_code,const QString &rep_message,const QString &tag)> error_callback=[](const int &code,const int &rep_code,const QString &rep_message,const QString &tag){});
extern void send_socket_message(QWebSocket *websocket,const int &code ,const QJsonObject &data,const QString &tag="");
QString format_unix_time(int unix_time);
#endif // UTIL_H
